#ifndef WeatherWidget_H
#define WeatherWidget_H

#include <QWidget>
#include <QProgressDialog>
#include "OCOsg2Cesium/converter/ObliqueTo3DTiles.h"
#include "OCOsg2Cesium/gltfConfig.h"
#include "OCMain/FileUtil.h"
#include "OCGrib/GribReader.h"
#include "OCNetCDF/NetCDFReader.h"

QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QPushButton;
class QSpinBox;
class QTextEdit;
class QCheckBox;
class QComboBox;
class QListView;
class QStringListModel;
class QItemSelection;
QT_END_NAMESPACE

//! [ObliqueWidget definition]
class WeatherWidget : public QWidget
{
    Q_OBJECT

public:
    WeatherWidget(QWidget *parent = nullptr);
    ~WeatherWidget();
    virtual void showEvent(QShowEvent*) override;
private slots:
    void onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
protected:
    void keyPressEvent(QKeyEvent* event) override;
    void keyReleaseEvent(QKeyEvent* event) override;
private:
    QCheckBox* setAbsoluteValue;
    QCheckBox* exportUV;

    QCheckBox* reverseZ;
    QCheckBox* gzipCompress;

    QLabel* clipMinZLabel;
    QLabel* clipMaxZLabel;
    QComboBox* clipMinZ;
    QComboBox* clipMaxZ;

    QLineEdit* isoValuesEdit;
    QCheckBox* isoValueCheck;


    QString lastFileName;
    QString lastFileName2;
    bool isNC = false;
    Json::Value varsObj;
    int styleID = 2;
    OCPP::VolumeWriter* getMinMaxWriter();
    OCPP::VolumeWriter* getMarchingCubeWriter();
    OCPP::String getClipStr();
    OCPP::StringVector getSrcFileList();
    void selectFile1();
    void selectFile2();
    void selectPath1();
    void exportData();
    bool exportGrid(OCPP::VolumeOptions volumeOptions, int exportLevel, int exportTime);
    bool exportNc(OCPP::VolumeOptions volumeOptions, int exportLevel, int exportTime);
    void touchFile2();
    void touch();
    void touchVar();
    void touchTime();
    void touchLevel();
    QString var1;
    QString var2;

    QLabel* fileLabel1;
    QLabel* fileLabel2;
    QLabel* pathLabel1;

    QLabel* extentLabel;
    QCheckBox* extentCheck;
    QLabel* extentLabelW;
    QLabel* extentLabelS;
    QLabel* extentLabelE;
    QLabel* extentLabelN;
    QLineEdit* extentEditW;
    QLineEdit* extentEditS;
    QLineEdit* extentEditE;
    QLineEdit* extentEditN;

    //
    QPushButton* minmaxButton;
    void minmaxVar();

    QLabel* infoLabel;

    QLineEdit *fileEdit1;
    QLineEdit* fileEdit2;
    QLineEdit* pathEdit1;

    QLabel* varLabel;
    QLabel* varLabelTip;
    QLabel* varStyle1;
    QListView* varListView;
    QStringListModel* varListModel = NULL;

    QLabel* timeLabel;
    QCheckBox* timeCheck;
    QListView* timeListView;
    QStringListModel* timeListModel = NULL;

    QLabel* levelLabel;
    QListView* levelListView;
    QCheckBox* levelCheck;
    QCheckBox* levelMergeCheck;
    QStringListModel* levelListModel = NULL;

    QLabel* styleLabel;
    QListView* styleListView;
    QStringListModel* styleListModel = NULL;

    QLineEdit* nodataEdit;
    QCheckBox* nodataCheck;

    QCheckBox* encodeMinLabel;
    QLabel* encodeMaxLabel;
    QLineEdit* encodeMinEdit;
    QLineEdit* encodeMaxEdit;

    QTextEdit* infoEdit;
    QPushButton* fileButton1;
    QCheckBox* fileCheck1;
    QPushButton* fileButton2;
    QPushButton* fileClearButton2;
    QPushButton* pathButton1;
    QPushButton* pathOpenButton1;
    QPushButton* startButton;

    std::unique_ptr<OCPP::GribReader> gribReader1;
    std::unique_ptr<OCPP::NetCDFReader> netcdfReader1;
    std::unique_ptr<OCPP::GribReader> gribReader2;
    std::unique_ptr<OCPP::NetCDFReader> netcdfReader2;

    bool firstShow = true;
};
//! [ObliqueWidget definition]

#endif // WINDOW_H
